/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * DeleteLayerForm.java
 *
 * Created on 23-mei-2011, 12:45:23
 */
package tasks.ui.architecture;

/**
 *
 * @author Tim Hofman Laptop
 */
public class DeleteLayerForm extends javax.swing.JPanel {

    /** Creates new form DeleteLayerForm */
    public DeleteLayerForm() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        deleteLayer = new javax.swing.JButton();
        deleteLayerErrorMsg = new javax.swing.JLabel();

        deleteLayer.setText("Delete layer");
        deleteLayer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteLayerActionPerformed(evt);
            }
        });

        deleteLayerErrorMsg.setForeground(java.awt.Color.red);
        deleteLayerErrorMsg.setPreferredSize(new java.awt.Dimension(400, 0));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(deleteLayer)
                    .addComponent(deleteLayerErrorMsg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(deleteLayerErrorMsg, javax.swing.GroupLayout.DEFAULT_SIZE, 14, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(deleteLayer))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void deleteLayerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteLayerActionPerformed
        if (this.controller.getSelectedLayer() != null) {
            this.controller.removeLayer(this.controller.getSelectedLayer());
            deleteLayerErrorMsg.setText("");
        } 
        else {
            deleteLayerErrorMsg.setText("The layer cannot be deleted, because there is no layer selected.");
        }
    }//GEN-LAST:event_deleteLayerActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton deleteLayer;
    private javax.swing.JLabel deleteLayerErrorMsg;
    // End of variables declaration//GEN-END:variables
    private ArchitectureController controller;

    public void setController(ArchitectureController controller) {
        this.controller = controller;
    }
}
